'''
@Project ：my_python_project 
@File    ：map、filter、reduce了解.py
@IDE     ：PyCharm 
@Author  ：xionglinhui
@Date    ：2024/8/27 上午8:51 
'''
# ========================map的应用(了解)
# l=['alex','lxx','wxx','薛贤妻']
# new_l=(name+'_dsb' for name in l)
# print(new_l)

# res=map(lambda name:name+'_dsb',l)
# print(res) # 生成器
# ========================filter的应用（了解）
# l=['alex_sb','lxx_sb','wxx','薛贤妻']
# res=(name for name in l if name.endswith('sb'))
# print(res)

# res=filter(lambda name:name.endswith('sb'),l)
# print(res)

# ========================reduce的应用(了解)
from functools import reduce
res=reduce(lambda x,y:x+y,[1,2,3],10) # 16
print(res)

res=reduce(lambda x,y:x+y,['a','b','c']) # 'a','b'
print(res)

